/*
 * QTeXPreview
 * Copyright (C) 2008, Philip Pronin (philip.pronin@gmail.com)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef TOOLBOXTABCFG_H
#define TOOLBOXTABCFG_H

#include <QDialog>
#include <QItemSelection>
#include "ui_toolBoxTabConfig.h"

QT_FORWARD_DECLARE_CLASS(QDataWidgetMapper)

struct ToolBoxCommand {
	bool active;
	QString title, tex, image;
	int cursor;

	ToolBoxCommand(const QString& _title = QString(), bool _active = true) :
		active(_active), title(_title), tex(""), image(""), cursor(0) {}
};

typedef QList<ToolBoxCommand> ToolBoxCommandList;

class ToolBoxTabConfig : public QDialog, private Ui_ToolBoxTabConfig {
	Q_OBJECT

public:
	ToolBoxTabConfig(QWidget* parent = NULL);
	virtual ~ToolBoxTabConfig() {}

	ToolBoxCommandList getCommandList() const;
	void setCommandList(ToolBoxCommandList list);

private:
	void addCommand(const ToolBoxCommand& cmd);

private slots:
	void renderImage();
	void commandChanged();
	void addItem();
	void selectionChanged(const QItemSelection& selected);
	void autoGenImage();
	void copyImage();
	void autoGenCursorPos();

private:
	QDataWidgetMapper* mapper;
};

#endif /* TOOLBOXTABCFG_H */
